<?php

namespace app\common\model\forest;

use app\common\model\User;
use think\Model;


class Member extends Model
{





    // 表名
    protected $name = 'forest_member';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'image_str',
    ];
    public function getImageStrAttr($value, $data)
    {
        return $data['image'] ? cdnurl($data['image'], true) : '';
    }

    public static function getForestMemberList($uid)
    {
        if ($uid) {
            $user = User::get($uid);
        }
        $list = self::all();
        foreach ($list as &$v) {
            $v->is_open = false;
            if (isset($user)&&$user->forest_level >= $v->id&&$user->validitytime>=time()) {
                $v->is_open = true;
            }
        }
        return $list;
    }
}
